package com.springcloud.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springcloud.dao.LogShowDao;
import com.springcloud.model.SysLogModel;
import com.springcloud.service.LogShowService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LogShowServiceImpl extends ServiceImpl<LogShowDao, SysLogModel> implements LogShowService {
    @Resource
    private  LogShowDao logShowDao;

    @Override
    public List<SysLogModel> showLog() {
        QueryWrapper<SysLogModel> queryWrapper=new QueryWrapper<>();
        queryWrapper.select("*");
        return logShowDao.selectList(queryWrapper);
    }

    @Override
    public List<SysLogModel> selectLogs(SysLogModel model) {
        QueryWrapper<SysLogModel> wrapper=new QueryWrapper<>();
        wrapper.select("*")
                .like(model.getUser_name()!=null,"user_name",model.getUser_name())
                .like(model.getCreate_time()!=null,"create_time",model.getCreate_time())
                .like(model.getOptIp()!=null,"optIp",model.getOptIp())
                .like(model.getContent()!=null,"content",model.getContent());
        return logShowDao.selectList(wrapper);
    }
}
